﻿package net.wangit.jdbc.sqltype;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;

public class DoubleSqlType extends NullableSqlType {

	private static final long serialVersionUID = 1L;

	public DoubleSqlType() {
	}

	public String get(ResultSet rs, String name) throws SQLException {
		double value = rs.getDouble(name);
		if (rs.wasNull())
			return null;
		else
			return Double.toString(value);
	}

	protected void setNotNull(PreparedStatement st, String value, int index)
			throws SQLException {
		st.setDouble(index, Double.parseDouble(value));
	}

	public int sqlType() {
		return Types.DOUBLE;
	}
}
